//
// Created by 谢哲 on 2021/4/19.
//

#include <iostream>
#include <vector>
using namespace std;

vector<int> vdata;

int find_k(int l, int r, int k) {
    if (r-l<=1) {
        return vdata[l];
    }

    int i=l, j=r-1;
    int key = vdata[l];
    bool flag = true;
    while(i<j) {
        if (flag) {
            if (vdata[j]<key) {
                vdata[i] = vdata[j];
                flag = false;
                ++i;
            }
            else --j;
        }
        else {
            if (vdata[i]>key) {
                vdata[j] = vdata[i];
                flag = true;
                --j;
            }
            else ++i;
        }
    }

    vdata[i] = key;
    if (i-l<k) {
        return find_k(i+1, r, k-(i-l)-1);
    }
    else if (i-l>k) {
        return find_k(l, i, k);
    }
    else return vdata[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, k;
    cin >> n >> k;

    vdata.resize(n, 0);

    for (int i=0;i<n;++i) {
        cin >> vdata[i];
    }

    cout << find_k(0, n, k);

    return 0;
}